/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */

#ifndef __BOARD_CONFIG_H__
#define __BOARD_CONFIG_H__

#include <pin_name.h>

/* 系统 */
//1:1.2V  2:1.0V  3:1.4V
#define SOC_DSP_LDO_LEVEL 3

/* console */
#define CONSOLE_TXD PA4
#define CONSOLE_RXD PA5
#define CONSOLE_TXD_FUNC PA4_UART2_TX
#define CONSOLE_RXD_FUNC PA5_UART2_RX
#define CONSOLE_UART_IDX 1

/* LED */
#define PIN_LED_R  -1
#define PIN_LED_G  -1
#define PIN_LED_B  -1
#define LED_FLIP_FLAG  0  /* 高电平亮 */

#define AW9523_ENABLED
#define AW9523_RST_PIN  PD1

#define AW2013_ENABLED
#define ADD2010_ENABLED

/* RTC */
#define CONFIG_RTC_EN 1

/* 音频 */
#define PIN_PA_MUTE  PD7
#define CONFIG_VOL_MAX    (90)
#define CONFIG_LEFT_GAIN  (-1) /* 88 左声道固定 -> REF */
#define CONFIG_RIGHT_GAIN (-1) /* 右声道可调 -> PA */
#define CONFIG_MIC_GAIN   (3) /* MIC初始20dB, 该值在20dB基础上增加的dB数 */

/* EQ */
#define APP_EQ_EN 0 /* 软件EQ使能配置 */

/* WiFi */
#define WIFI_SD_CMD PC4
#define WIFI_SD_CMD_FUNC PC4_SD_CMD_CMD
#define WIFI_SD_CLK PC3
#define WIFI_SD_CLK_FUNC PC3_SD_CLK
#define WIFI_SD_DAT0 PC2
#define WIFI_SD_DAT0_FUNC PC2_SD_D0
#define WIFI_SD_DAT1 PC1
#define WIFI_SD_DAT1_FUNC PC1_SD_D1
#define WIFI_SD_DAT2 PC6
#define WIFI_SD_DAT2_FUNC PC6_SD_D2
#define WIFI_SD_DAT3 PC5
#define WIFI_SD_DAT3_FUNC PC5_SD_D3
#define WLAN_ENABLE_PIN PC8
#define WLAN_POWER_PIN PC0

#define PIN_WL_WAKE_HOST PA6
#define PIN_WL_WAKE_HOST_GROUP LPM_DEV_MASK_GENERAL_GPIO2

/* BT */
#define BT_UART_IDX 0
#define BT_UART_TXD PB0
#define BT_UART_RXD PB1
#define BT_UART_TXD_FUNC PB0_UART1_TX
#define BT_UART_RXD_FUNC PB1_UART1_RX
#define BT_DIS_PIN PC7

/* TF Card */
#define TF_SDIO_CMD PC11
#define TF_SDIO_CMD_FUNC PC11_SDIO_CMD
#define TF_SDIO_CLK PC10
#define TF_SDIO_CLK_FUNC PC10_SDIO_CLK
#define TF_SDIO_DAT0 PC9
#define TF_SDIO_DAT0_FUNC PC9_SDIO_D0
#define TF_SDIO_DAT1 PC8
#define TF_SDIO_DAT1_FUNC PC8_SDIO_D1
#define TF_SDIO_SDA PC13
#define TF_SDIO_SDA_FUNC PC13_I2C2_SDA
#define TF_SDIO_SCL PC12
#define TF_SDIO_SCL_FUNC PC12_I2C2_SCL

/* LPM */
#define MAX_LPM_WAKESRC_COUNT 5
/* CONFIG_TEST_LPMVAD: 简单唤醒算法
*  CONFIG_MIT_LPMVAD:  复杂唤醒算法 */
#define CONFIG_MIT_LPMVAD 1
#define LPM_WL_WAKE_HOST_EN 1   /* WIFI 唤醒主控 */
#define LPM_IDLE_CHECK_TIME 30  /* 秒 */
#define LPM_VAD_PIN PA1         /* VAD低功耗唤醒引脚 */
#define LPM_DEEP_WAKEUP_PIN PA1 /* 深度睡眠唤醒引脚 */

/* 按键 */
#define PIN_ADC_KEY     PA1
#define PIN_ADC_KEY2    PA3
#define KEY_ADC_VAL1    887
#define KEY_ADC_VAL2    563
#define KEY_ADC_VAL3    1595
#define KEY_ADC_VAL4    665
#define KEY_ADC_VAL5    1595
#define KEY_ADC_VAL6    563
#define KEY_ADC_VAL7    887
#define KEY_ADC_VAL8    665
#define KEY_AD_VAL_OFFSET 60  /* 按键值误差允许 */

#define VAD_ADC_VAL_MAX   KEY_ADC_VAL3 + KEY_AD_VAL_OFFSET /* 最大值 + 误差值 */
#define VAD_ADC_VAL_MIN   KEY_ADC_VAL6 - KEY_AD_VAL_OFFSET /* 最小值 - 误差值 */


#define PIN_TOUCH_PAD          PB8

/* 模拟电源按键 */
#define SIMULATED_POWER_KEY 1
#define POWER_KEY_ADC   /* 配置则读取模拟电源键adc值，不配置则读取模拟电源键gpio值 */
#define POWER_KEY_PIN       PA3
#define POWER_KEY_VAL_MAX   650
#define POWER_KEY_VAL_MIN   450

/* SD卡侦测 */
#define CONFIG_SD_CARD_EN 1
#define SD_DETECT_PIN     -1 /* SD卡侦测pin口 GPIO1_16 */
#define SD_DETECT_FUNC    -1 /* 该pin口的FUNC */

/* ADC电池侦测 */
#define CONFIG_BATTERY_ADC 0      /* 电池检测 */
#define PIN_BATTERY_ADC -1        /* 电池电量检测，-1：变量模拟一个电压值 */
#define PIN_BATTERY_CHARGE_PIN -1 /* 充电状态检测, -1不检查 */

#define BATTERY_AVG_ROUND 10  /* 电池电量检查的平均次数 */
#define BATTERY_VOLT_LOW 3800 /* 小于该值控制音量输出 */
#define BATTERY_VOLT_MIN 3700 /* 电量小于该值关机 */
#define BATTERY_VOLT_DIFF 100 /* 平均时候删除异常点的阈值 */
#endif /* __BOARD_CONFIG_H__ */
